/*
 *
 * -------------------------------------------------------------------------------------------------
 *                            COPYRIGHT(C) BOCO HEALTH 2016
 * -------------------------------------------------------------------------------------------------
 *
 * =================================================================================================
 *  *HISTORY
 *
 *      Tag                Date            Author           Description
 * =================================================================================================
 *      created            2017/1/17      caodailu        create
 * =================================================================================================
 *
 *
 */

package com.boco.familyuser.view.custom_im;

import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.mobileim.aop.Pointcut;
import com.alibaba.mobileim.aop.custom.IMContactsUI;
import com.boco.familyuser.R;
import com.boco.familyuser.utils.ImStatusBarUtils;
import com.boco.familyuser.view.im.FindContactActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 联系人界面UI的定制点(根据需要实现相应的接口来达到联系人界面)，不设置则使用云旺默认的实现
 * 调用方设置的回调，必须继承BaseAdvice 根据不同的需求实现 不同的 开放的 Advice
 * com.alibaba.mobileim.aop.pointcuts包下开放了不同的Advice.通过实现多个接口，组合成对不同的ui界面的定制
 * 需要在application中将这个Advice绑定。设置以下代码
 * AdviceBinder.bindAdvice(PointCutEnum.CONTACTS_UI_POINTCUT, ContactsUICustom.class);
 *
 * @author shuheng
 */
public class ContactsUICustom extends IMContactsUI {

    @BindView(R.id.head_center_text)
    TextView mHeadCenterText;
    @BindView(R.id.head_right_image)
    ImageView mHeadRightImage;
    @BindView(R.id.head_left_image)
    ImageView headLeftImage;

    private Context mContext;
    private Fragment mFragment;

    public ContactsUICustom(Pointcut pointcut) {
        super(pointcut);

    }

    @Override
    public View getCustomTitle(Fragment fragment, Context context, LayoutInflater inflater) {
        View view = inflater.inflate(R.layout.include_head_top, new RelativeLayout(context), false);
        mContext = context;
        mFragment = fragment;
        ButterKnife.bind(this, view);
        ImStatusBarUtils.initStatusBar(fragment.getActivity());
        headLeftImage.setVisibility(View.VISIBLE);
        mHeadCenterText.setVisibility(View.VISIBLE);
        mHeadRightImage.setVisibility(View.VISIBLE);
        mHeadCenterText.setText("联系人");
        mHeadRightImage.setImageResource(R.mipmap.add_sign);

        return view;
    }

    @OnClick({R.id.head_left_show, R.id.head_right_show})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.head_left_show:
                mFragment.getActivity().finish();
                break;
            case R.id.head_right_show:
                Intent intent = new Intent().setClass(mContext, FindContactActivity.class);
                mContext.startActivity(intent);
                break;
        }
    }
}